//
//  RequestTool.h
//  解税宝
//
//  Created by 边文辉 on 2016/10/27.
//  Copyright © 2016年 jieshuibao. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface RequestTool : NSObject

/**
 * AF数据请求
 */
+ (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
                            parameters:(nullable id)parameters
                              progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
                               success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
                               failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

+ (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
                             parameters:(nullable id)parameters
                               progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
                                success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
                                failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/**
 * 上传文件
 */
+ (NSURLSessionDataTask *)postFile:(NSString *)URLString
                        parameters:(id)parameters
         constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
                          progress:(void (^)(NSProgress *uploadProgress))uploadProgress
                           success:(void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
                           failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;


/**
 * 下载文件
 */
+ (NSURLSessionDownloadTask *)downLoadFile:(NSString *)URLString
                                  progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                               destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                         completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;


/*json
 * @brief 把格式化的JSON格式的字符串转换成字典
 * @param jsonString JSON格式的字符串
 * @return 返回字典
 */
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;


/*json
 * @brief 把字典转换成字符串
 * @param jsonString JSON格式的字符串
 * @return 返回字符串
 */
+(NSString *)URLEncryOrDecryString:(NSDictionary *)paramDict IsHead:(BOOL)_type;


@end

NS_ASSUME_NONNULL_END
